/*  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef options_hh
#define options_hh

#include <lua.h>
#include <map>
#include <list>
#include <string>

namespace luge {

/**
 * a list of command line argument parameters.
 */
typedef std::list <std::string> string_list;
/**
 * maps options to their arguments.
 */
typedef std::map <std::string, string_list> opt_map;

/**
 * options for the interpreter.
 */
struct luge_opt
{
  static luge_opt defaults ();
  /**
   * verbosity level between 0 and 2.
   */
  int verbosity;
  /**
   * display help.
   */
  bool help;
  /**
   * true, if --opencl was given.
   */
  bool enable_opencl;
  /**
   * --version was given.
   */
  bool display_version;
  /**
   * there were errors in the options.
   */
  bool found_errors;
  /**
   * the name of the script.
   */
  std::string script_name;
};

/**
 * stores all options.
 */
struct options
{
  /**
   * internal options for the interpreter.
   */
  luge_opt interpreter_opt;
  /**
   * script arguments are collected into this map.
   */
  opt_map script_opt;
};

/**
 * transform options to an opt-map.
 * remaining non-argument options are put into "args".
 */
options parse_args (int argc, char **argv);

/**
 * bind the argument map to global variables.
 */
void bind_args (lua_State *ls, const opt_map &map);

/**
 * display the usage info.
 */
void usage (const std::string &name);

} /* namespace luge */

#endif
